home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / tk / listbox.man < prev    next >
Encoding:
Text File  |  1992-08-24  |  12.5 KB  |  413 lines

  1. '\"
  2. '\" Copyright 1990 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/wish/man/RCS/listbox.man,v 1.11 92/06/03 16:56:25 ouster Exp $ SPRITE (Berkeley)
  11. '/" 
  12. .\" The definitions below are for supplemental macros used in Sprite
  13. .\" manual entries.
  14. .\"
  15. .\" .HS name section [date [version]]
  16. .\"    Replacement for .TH in other man pages.  See below for valid
  17. .\"    section names.
  18. .\"
  19. .\" .AP type name in/out [indent]
  20. .\"    Start paragraph describing an argument to a library procedure.
  21. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  22. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  23. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  24. .\"    needed;  use .AS below instead)
  25. .\"
  26. .\" .AS [type [name]]
  27. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  28. .\"    name are examples of largest possible arguments that will be passed
  29. .\"    to .AP later.  If args are omitted, default tab stops are used.
  30. .\"
  31. .\" .BS
  32. .\"    Start box enclosure.  From here until next .BE, everything will be
  33. .\"    enclosed in one large box.
  34. .\"
  35. .\" .BE
  36. .\"    End of box enclosure.
  37. .\"
  38. .\" .VS
  39. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  40. .\"    of man pages.
  41. .\"
  42. .\" .VE
  43. .\"    End of vertical sidebar.
  44. .\"
  45. .\" .DS
  46. .\"    Begin an indented unfilled display.
  47. .\"
  48. .\" .DE
  49. .\"    End of indented unfilled display.
  50. .\"
  51. '\"    # Heading for Sprite man pages
  52. .de HS
  53. .if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  54. .if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  55. .if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  56. .if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  57. .if t .wh -1.3i ^B
  58. .nr ^l \\n(.l
  59. .ad b
  60. ..
  61. '\"    # Start an argument description
  62. .de AP
  63. .ie !"\\$4"" .TP \\$4
  64. .el \{\
  65. .   ie !"\\$2"" .TP \\n()Cu
  66. .   el          .TP 15
  67. .\}
  68. .ie !"\\$3"" \{\
  69. .ta \\n()Au \\n()Bu
  70. \&\\$1    \\fI\\$2\\fP    (\\$3)
  71. .\".b
  72. .\}
  73. .el \{\
  74. .br
  75. .ie !"\\$2"" \{\
  76. \&\\$1    \\fI\\$2\\fP
  77. .\}
  78. .el \{\
  79. \&\\fI\\$1\\fP
  80. .\}
  81. .\}
  82. ..
  83. '\"    # define tabbing values for .AP
  84. .de AS
  85. .nr )A 10n
  86. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  87. .nr )B \\n()Au+15n
  88. .\"
  89. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  90. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  91. ..
  92. '\"    # BS - start boxed text
  93. '\"    # ^y = starting y location
  94. '\"    # ^b = 1
  95. .de BS
  96. .br
  97. .mk ^y
  98. .nr ^b 1u
  99. .if n .nf
  100. .if n .ti 0
  101. .if n \l'\\n(.lu\(ul'
  102. .if n .fi
  103. ..
  104. '\"    # BE - end boxed text (draw box now)
  105. .de BE
  106. .nf
  107. .ti 0
  108. .mk ^t
  109. .ie n \l'\\n(^lu\(ul'
  110. .el \{\
  111. .\"    Draw four-sided box normally, but don't draw top of
  112. .\"    box if the box started on an earlier page.
  113. .ie !\\n(^b-1 \{\
  114. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  115. .\}
  116. .el \}\
  117. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  118. .\}
  119. .\}
  120. .fi
  121. .br
  122. .nr ^b 0
  123. ..
  124. '\"    # VS - start vertical sidebar
  125. '\"    # ^Y = starting y location
  126. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  127. .de VS
  128. .mk ^Y
  129. .ie n 'mc \s12\(br\s0
  130. .el .nr ^v 1u
  131. ..
  132. '\"    # VE - end of vertical sidebar
  133. .de VE
  134. .ie n 'mc
  135. .el \{\
  136. .ev 2
  137. .nf
  138. .ti 0
  139. .mk ^t
  140. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  141. .sp -1
  142. .fi
  143. .ev
  144. .\}
  145. .nr ^v 0
  146. ..
  147. '\"    # Special macro to handle page bottom:  finish off current
  148. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  149. '\"    # page bottom macro.
  150. .de ^B
  151. .ev 2
  152. 'ti 0
  153. 'nf
  154. .mk ^t
  155. .if \\n(^b \{\
  156. .\"    Draw three-sided box if this is the box's first page,
  157. .\"    draw two sides but no top otherwise.
  158. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  159. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  160. .\}
  161. .if \\n(^v \{\
  162. .nr ^x \\n(^tu+1v-\\n(^Yu
  163. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  164. .\}
  165. .bp
  166. 'fi
  167. .ev
  168. .if \\n(^b \{\
  169. .mk ^y
  170. .nr ^b 2
  171. .\}
  172. .if \\n(^v \{\
  173. .mk ^Y
  174. .\}
  175. ..
  176. '\"    # DS - begin display
  177. .de DS
  178. .RS
  179. .nf
  180. .sp
  181. ..
  182. '\"    # DE - end display
  183. .de DE
  184. .fi
  185. .RE
  186. .sp .5
  187. ..
  188. .HS listbox cmds
  189. .BS
  190. '\" Note:  do not modify the .SH NAME line immediately below!
  191. .SH NAME
  192. listbox \- Create and manipulate listbox widgets
  193. .SH SYNOPSIS
  194. \fBlistbox\fI \fIpathName \fR?\fIoptions\fR?
  195. .SH "STANDARD OPTIONS"
  196. .LP
  197. .nf
  198. .ta 4c 8c 12c
  199. .VS
  200. \fBbackground\fR    \fBforeground\fR    \fBselectBackground\fR    \fByScrollCommand\fR
  201. \fBborderWidth\fR    \fBfont\fR    \fBselectBorderWidth\fR
  202. \fBcursor\fR    \fBgeometry\fR    \fBselectForeground\fR
  203. \fBexportSelection\fR    \fBrelief\fR    \fBxScrollCommand\fR
  204. .VE
  205. .fi
  206. .LP
  207. See the ``options'' manual entry for details on the standard options.
  208. .SH "WIDGET-SPECIFIC OPTIONS"
  209. .ta 4c
  210. .LP
  211. None.
  212. .BE
  213.  
  214. .SH DESCRIPTION
  215. .PP
  216. The \fBlistbox\fR command creates a new window (given by the
  217. \fIpathName\fR argument) and makes it into a listbox widget.
  218. Additional
  219. options, described above, may be specified on the command line
  220. or in the option database
  221. to configure aspects of the listbox such as its colors, font,
  222. text, and relief.  The \fBlistbox\fR command returns its
  223. \fIpathName\fR argument.  At the time this command is invoked,
  224. there must not exist a window named \fIpathName\fR, but
  225. \fIpathName\fR's parent must exist.
  226. .PP
  227. A listbox is a widget that displays a list of strings, one per line.
  228. When first created, a new listbox has no elements in its list.
  229. Elements may be added or deleted using widget commands described
  230. below.  In addition, one or more elements may be selected as described
  231. below.
  232. .VS
  233. If a listbox is exporting its selection (see \fBexportSelection\fR
  234. option), then it will observe the standard X11 protocols
  235. .VE
  236. for handling the selection;  listbox selections are available
  237. as type \fBSTRING\fR, consisting of a Tcl list with one entry
  238. for each selected element.
  239. .PP
  240. For large lists only a subset of the list elements will be
  241. displayed in the listbox window at once;  commands described below
  242. may be used to change the view in the window.  Listboxes allow
  243. .VS
  244. scrolling in both directions using the standard \fBxScrollCommand\fR
  245. and \fByScrollCommand\fR options.
  246. .VE
  247. They also support scanning, as described below.
  248.  
  249. .SH "WIDGET COMMAND"
  250. .PP
  251. The \fBlistbox\fR command creates a new Tcl command whose
  252. name is \fIpathName\fR.  This
  253. command may be used to invoke various
  254. operations on the widget.  It has the following general form:
  255. .DS C
  256. \fIpathName option \fR?\fIarg arg ...\fR?
  257. .DE
  258. \fIOption\fR and the \fIarg\fRs
  259. determine the exact behavior of the command.  The following
  260. commands are possible for listbox widgets:
  261. .TP
  262. \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
  263. Query or modify the configuration options of the widget.
  264. If no \fIoption\fR is specified, returns a list describing all of
  265. the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
  266. information on the format of this list).  If \fIoption\fR is specified
  267. with no \fIvalue\fR, then the command returns a list describing the
  268. one named option (this list will be identical to the corresponding
  269. sublist of the value returned if no \fIoption\fR is specified).  If
  270. one or more \fIoption\-value\fR pairs are specified, then the command
  271. modifies the given widget option(s) to have the given value(s);  in
  272. this case the command returns an empty string.
  273. \fIOption\fR may have any of the values accepted by the \fBlistbox\fR
  274. command.
  275. .TP
  276. \fIpathName \fBcurselection\fR
  277. .VS
  278. Returns a list containing the indices of
  279. all of the elements in the listbox that are currently selected.
  280. If there are no elements selected in the listbox then an empty
  281. string is returned.
  282. .VE
  283. .TP
  284. \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
  285. Delete one or more elements of the listbox.  \fIFirst\fR and \fIlast\fR
  286. give the integer indices of the first and last elements in the range
  287. to be deleted.  If \fIlast\fR isn't specified it defaults to
  288. \fIfirst\fR, i.e. a single element is deleted.  An index of
  289. \fB0\fR corresponds to the first element in the listbox.  Either
  290. \fIfirst\fR or \fIlast\fR may be specified as \fBend\fR, in which
  291. case it refers to the last element of the listbox.  This command
  292. returns an empty string
  293. .TP
  294. \fIpathName \fBget \fIindex\fR
  295. Return the contents of the listbox element indicated by \fIindex\fR.
  296. \fIIndex\fR must be a non-negative integer (0 corresponds to
  297. the first element in the listbox), or it may also be specified as
  298. \fBend\fR to indicate the last element in the listbox.
  299. .TP
  300. \fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR?
  301. Insert zero or more new elements in the list just before the
  302. element given by \fIindex\fR.  If \fIindex\fR is specified as
  303. \fBend\fR then the new elements are added to the end of the
  304. list.  Returns an empty string.
  305. .TP
  306. \fIpathName \fBnearest \fIy\fR
  307. Given a y-coordinate within the listbox window, this command returns
  308. the index of the (visible) listbox element nearest to that y-coordinate.
  309. .TP
  310. \fIpathName \fBscan\fR \fIoption args\fR
  311. This command is used to implement scanning on listboxes.  It has
  312. two forms, depending on \fIoption\fR:
  313. .RS
  314. .TP
  315. \fIpathName \fBscan mark \fIx y\fR
  316. .VS
  317. Records \fIx\fR and \fIy\fR and the current view in the listbox
  318. window;  used in conjunction with later \fBscan dragto\fR commands.
  319. Typically this command is associated with a mouse button press in
  320. the widget.  It returns an empty string.
  321. .TP
  322. \fIpathName \fBscan dragto \fIx y\fR.
  323. This command computes the difference between its \fIx\fR and \fIy\fR
  324. arguments and the \fIx\fR and \fIy\fR arguments to the last
  325. \fBscan mark\fR command for the widget.
  326. It then adjusts the view by 10 times the
  327. difference in coordinates.  This command is typically associated
  328. .VE
  329. with mouse motion events in the widget, to produce the effect of
  330. dragging the list at high speed through the window.  The return
  331. value is an empty string.
  332. .RE
  333. .TP
  334. \fIpathName \fBselect \fIoption arg\fR
  335. This command is used to adjust the selection within a listbox.  It
  336. has several forms, depending on \fIoption\fR.  In all of the forms
  337. the index \fBend\fR refers to the last element in the listbox.
  338. .RS
  339. .TP
  340. \fIpathName \fBselect adjust \fIindex\fR
  341. Locate the end of the selection nearest to the element given by
  342. \fIindex\fR, and adjust that end of the selection to be at \fIindex\fR
  343. (i.e including but not going beyond \fIindex\fR).  The other
  344. end of the selection is made the anchor point for future
  345. \fBselect to\fR commands.  If the selection
  346. isn't currently in the listbox, then this command is identical to
  347. the \fBselect from\fR widget command.
  348. Returns an empty string.
  349. .TP
  350. \fIpathName \fBselect clear\fR
  351. .VS
  352. If the selection is in this listbox then it is cleared so that
  353. none of the listbox's elements are selected anymore.
  354. .VE
  355. .TP
  356. \fIpathName \fBselect from \fIindex\fR
  357. Set the selection to consist of element \fIindex\fR, and make
  358. \fIindex\fR the anchor point for future \fBselect to\fR widget
  359. commands.  Returns an empty string.
  360. .TP
  361. \fIpathName \fBselect to \fIindex\fR
  362. Set the selection to consist of the elements from the anchor
  363. point to element \fIindex\fR, inclusive.  The anchor point is
  364. determined by the most recent \fBselect from\fR or \fBselect adjust\fR
  365. command in this widget.  If the selection isn't in this widget,
  366. this command is identical to \fBselect from\fR.
  367. Returns an empty string.
  368. .RE
  369. .TP
  370. \fIpathName \fBsize\fR
  371. Returns a decimal string indicating the total number of elements
  372. in the listbox.  Returns an empty string.
  373. .TP
  374. \fIpathName \fBxview \fIindex\fR
  375. .VS
  376. Adjust the view in the listbox so that character position \fIindex\fR
  377. is displayed at the left edge of the widget.
  378. Returns an empty string.
  379. .TP
  380. \fIpathName \fByview \fIindex\fR
  381. Adjust the view in the listbox so that element \fIindex\fR is
  382. displayed at the top of the widget.
  383. If \fIindex\fR is specified as \fBend\fR it indicates the last
  384. element of the listbox.  Returns an empty string.
  385. .VE
  386.  
  387. .SH "DEFAULT BINDINGS"
  388. .PP
  389. .VS
  390. Tk automatically creates class bindings for listboxes that give them
  391. the following default behavior:
  392. .IP [1]
  393. When button 1 is pressed over a listbox, the element underneath the
  394. mouse cursor is selected.  The mouse can be dragged to select a
  395. range of elements.
  396. .IP [2]
  397. The ends of the selection can be adjusted by dragging with mouse
  398. button 1 while the shift key is down;  this will adjust the end
  399. of the selection that was nearest to the mouse cursor when button
  400. 1 was pressed.
  401. .IP [3]
  402. The view in the listbox can be adjusted by dragging with mouse button 2.
  403. .PP
  404. The behavior of listboxes can be changed by defining new bindings for
  405. individual widgets or by redefining the class bindings.
  406. In addition, the procedure \fBtk_listboxSingleSelect\fR may be
  407. invoked to change listbox behavior so that only a single element
  408. may be selected at once.
  409. .VE
  410.  
  411. .SH KEYWORDS
  412. listbox, widget
  413.